package com.demo.fulllink.service.impl;

import com.demo.fulllink.common.emum.ResponseErrorEnum;
import com.demo.fulllink.module.po.AccountPO;
import com.demo.fulllink.module.vo.ResponseVO;
import com.demo.fulllink.service.AccountService;
import com.demo.fulllink.service.StorageAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;

@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    private StorageAccountService storageAccountService;
    
    @Override
    public AccountPO findById(Serializable accountId) {
        return storageAccountService.findByID(accountId);
    }
    
    @Override
    public AccountPO findByName(Serializable accountName) {
        return storageAccountService.findByName(accountName);
    }
    
    @Override
    public ResponseVO checkAccount(Serializable accountId) {
        AccountPO po = storageAccountService.findByID(accountId);
        if (null == po) {
            return ResponseErrorEnum.PRODUCT_NOT_EXIST_ERROR.toResponseVO();
        }
        return ResponseVO.success(po);
    }
}
